#set(tableComment = table.getComment())
#set(entityClassName = table.buildEntityClassName())
#set(entityVarName = firstCharToLowerCase(entityClassName))
#set(serviceVarName = firstCharToLowerCase(table.buildServiceClassName()))
package #(packageConfig.controllerPackage);

import abg.core.domain.search.Psh;
import abg.core.domain.sys.SRS;
import com.mybatisflex.core.paginate.Page;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import jakarta.annotation.Resource;
import #(packageConfig.entityPackage).#(entityClassName);
import #(packageConfig.servicePackage).#(table.buildServiceClassName());
#if(controllerConfig.restStyle)
import org.springframework.web.bind.annotation.RestController;
#else
import org.springframework.stereotype.Controller;
#end
#if(controllerConfig.superClass != null)
import #(controllerConfig.buildSuperClassImport());
#end
#if(withSwagger && swaggerVersion.getName() == "FOX")
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
#end
#if(withSwagger && swaggerVersion.getName() == "DOC")
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
#end
import java.io.Serializable;
import java.util.List;

/**
 * #(tableComment) 控制层。
 *
 * @author #(javadocConfig.getAuthor())
 * @since #(javadocConfig.getSince())
 */
#if(controllerConfig.restStyle)
@RestController
#else
@Controller
#end
#if(withSwagger && swaggerVersion.getName() == "FOX")
@Api("#(tableComment)接口")
#end
#if(withSwagger && swaggerVersion.getName() == "DOC")
@Tag(name = "#(tableComment)接口")
#end
@RequestMapping("/#(firstCharToLowerCase(entityClassName))")
public class #(table.buildControllerClassName()) #if(controllerConfig.superClass)extends #(controllerConfig.buildSuperClassName()) #end {

    @Resource
    private #(table.buildServiceClassName()) #(serviceVarName);

    /**
     * 插入数据#(tableComment)
     */
    @PostMapping("insert")
    public SRS<Boolean> insert(#(entityClassName) #(entityVarName)) {
        return SRS.bySuccess(#(serviceVarName).insert(#(entityVarName)));
    }

    /**
     * 根据主键删除#(tableComment)
     *
     * @param ids 逗号分隔字符串
     */
    @PostMapping("delete")
    public SRS<Boolean> delete(String ids) {
        return SRS.bySuccess(#(serviceVarName).delete(ids));
    }

    /**
     * 根据主键更新#(tableComment)
     */
    @PostMapping("update")
    public SRS<Boolean> update(#(entityClassName) #(entityVarName)) {
        return SRS.bySuccess(#(serviceVarName).update(#(entityVarName)));
    }

    /**
     * 根据#(tableComment)主键获取详细信息。
     */
    @PostMapping("info")
    public SRS<#(entityClassName)> info(String id) {
        return SRS.bySuccess(#(serviceVarName).info(id));
    }

    /**
     * 分页查询#(tableComment)
     *
     * @param #(entityVarName) 实体搜索对象
     * @param psh 分页搜索对象
     */
    @GetMapping("page")
    public SRS<Page<#(entityClassName)>> page(#(entityClassName) #(entityVarName), Psh psh) {
        return SRS.bySuccess(#(serviceVarName).page(#(entityVarName), psh));
    }

}
